load("//test_utils.bzl", "assert_output")

export_file(
    name = "mylib.mli",
    src = "mylib.mli",
    visibility = [
        ":mylib",
        ":mylib__",
    ],
)

# buildifier: disable=no-effect
ocaml_library(
    name = "mylib__",
    srcs = [
        "mylib.ml",
        ":mylib.mli",
    ],
    compiler_flags = [
        "-no-alias-deps",
        "-w",
        "-49",
    ],
    visibility = [":mylib"],
) if not host_info().os.is_windows else None

# buildifier: disable=no-effect
ocaml_library(
    name = "mylib",
    srcs = [
        "mylib__A.ml",
        "mylib__B.ml",
    ],
    compiler_flags = [
        "-no-alias-deps",
        "-w",
        "-49",
        "-open",
        "Mylib",
    ],
    ocamldep_flags = [
        "-open",
        "Mylib",
        "-map",
        "$(location :mylib.mli)",
    ],
    visibility = ["PUBLIC"],
    deps = [":mylib__"],
) if not host_info().os.is_windows else None

# buildifier: disable=no-effect
ocaml_binary(
    name = "test-Mylib",
    srcs = ["test_Mylib.ml"],
    visibility = ["PUBLIC"],
    deps = [":mylib"],
) if not host_info().os.is_windows else None

# buildifier: disable=no-effect
assert_output(
    name = "test-Mylib-check",
    command = "$(exe_target :test-Mylib)",
    output = "Hello world!",
) if not host_info().os.is_windows else None
